﻿Imports System.Transactions
Imports Sistema_InformacionNaviera.BE
Imports Sistema_InformacionNaviera.DALC

Public Class ViajesBC
    Public Function ListaViajes(ByVal objViajesBE As ViajesBE) As List(Of ViajesBE)
        Dim objViajes As List(Of ViajesBE) = Nothing
        Dim objViajesDALC As ViajesDALC = Nothing
        objViajesDALC = New ViajesDALC
        objViajes = New List(Of ViajesBE)()
        objViajes = objViajesDALC.ListaViaje(objViajesBE)

        Return objViajes
    End Function

    'Public Function ListaNave(ByVal objViajesBE As ViajesBE) As List(Of ViajesBE)

    '    Dim objViajes As List(Of ViajesBE) = Nothing
    '    Dim objViajesDALC As ViajesDALC = Nothing
    '    objViajesDALC = New ViajesDALC
    '    objViajes = New List(Of ViajesBE)()
    '    objViajes = objViajesDALC.ListaNave(objViajesBE)

    '    Return objViajes
    'End Function

    Public Function ConsultaNaveViaje(ByVal objViajesBE As ViajesBE) As List(Of ViajesBE)

        Dim objViajes As List(Of ViajesBE) = Nothing
        Dim objViajesDALC As ViajesDALC = Nothing
        objViajesDALC = New ViajesDALC
        objViajes = New List(Of ViajesBE)()
        objViajes = objViajesDALC.ConsultaNaveViaje(objViajesBE)

        Return objViajes
    End Function

    Public Function EliminarNaveViaje(ByVal objNaveViajeBE As ViajesBE, bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope

        Using objScope
            Try
                Dim objNaveViajeDALC As ViajesDALC = Nothing
                objNaveViajeDALC = New ViajesDALC

                bExito = objNaveViajeDALC.EliminarNaveViaje(objNaveViajeBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return bExito
    End Function

    Public Function InsertarViajes(ByVal objViajesBE As ViajesBE, bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope

        Using objScope
            Try
                Dim objViajesDALC As ViajesDALC = Nothing
                objViajesDALC = New ViajesDALC

                bExito = objViajesDALC.InsertarViajes(objViajesBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Information, "Insertar Viajes")
            End Try
        End Using

        Return bExito
    End Function

    Public Function EditarViajes(ByVal objViajesBE As ViajesBE, bExito As Boolean, ByRef sMensaje As String) As Boolean

        Dim objScope As TransactionScope
        objScope = New TransactionScope

        Using objScope
            Try
                Dim objViajesDALC As ViajesDALC = Nothing
                objViajesDALC = New ViajesDALC

                bExito = objViajesDALC.EditarViajes(objViajesBE, bExito, sMensaje)

                objScope.Complete()
            Catch ex As Exception
                MsgBox(ex.Message, vbCritical, "Error del sistema")
                Return False
                Exit Function
            End Try
        End Using

        Return bExito
    End Function
End Class

 